from selenium.webdriver.common.by import By

from page_object.pages.BasePage import BasePage
from page_object.pages.ChatPage import ChatPage
from page_object.pages.NewDetailPage import NewDetailPage
from page_object.pages.ReleasePage import ReleasePage


class CirclePage(BasePage):
    _tv_release = (By.ID, 'tv_release')  # 发布按钮
    # 圈子页面
    def go_to_release_page(self):
        '''
        #去发布圈子页面
        :return:
        '''
        self.find(self._tv_release).click()
        return ReleasePage()

    def goto_news_detail(self):
        '''
        去动态详情页面
        :return:
        '''
        # #滑动直到找到text里面的元素，instance里面的参数是滑动第几个可以滑动的控件
        # self.driver.find_element_by_android_uiautomator(
        # 'new UiScrollable(new UiSelector().scrollable(true).instance(1)).scrollIntoView(new UiSelector().resourceId("com.daofeng.peiwan:id/bt_chat").instance(0));'
        # ).click()

        # self.swipe_to_element_by_text(1, '打招呼').click()
        self.find_by_xpath('关注').click()
        self.swipe_to_element_by_resource_id(1,'com.daofeng.peiwan:id/bt_comment').click()
        return NewDetailPage()